from appium.options.android import UiAutomator2Options
from appium import webdriver

from objects.protocol_page import ProtocolPage


class AgreeProtocolAction:

    def __init__(self):
        print('====点击知情同意====')

    def agreeProtocal(self, driver):
        try:
            protocol = ProtocolPage(driver)
            protocol.protocolAndAgree_click()

        except Exception as e:
            raise '点击知情同意按钮失败' + e


if __name__ == '__main__':
    desired_caps = {
        "platformName": "Android",
        "deviceName": "Q7PDU19731008305",
        "appPackage": "com.sankuai.movie",
        "appActivity": "com.sankuai.movie.MovieMainActivity",
        "automationName": "UiAutomator2",
        # "noReset": True
    }

    print("Desired Capabilities: ", desired_caps)

    driver = webdriver.Remote("http://localhost:4723", options=UiAutomator2Options().load_capabilities(desired_caps))

    protocol_action = AgreeProtocolAction()

    protocol_action.agreeProtocal(driver)

    driver.quit()